/*************************************************************************
	> File Name: 4-valid_data.c
	> Author: Wang Bo
	> Mail: 1276106221@qq.com
	> Created Time: 2020年10月17日 星期六 18时07分42秒
 ************************************************************************/

#include <stdio.h>
#include <stdlib.h>
int month[13] = {
    0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31
};

int check(int y, int m, int d) {
    if (m <= 0 || d <= 0 || m > 12) return 0;
    if ((y % 4 == 0 && y % 100) || y % 400) month[2] += 1;
    return d <= month[m];
}

int main() {
    int y, m, d;
    scanf("%d%d%d", &y, &m, &d);
    /*if (check(y, m, d)) {
        printf("YES\n");
    } else {
        printf("NO\n");
    }*/
    printf("%s\n", check(y, m, d) ? "YES" : "NO");
    return 0;
}
